#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
class person {
public:
	void FirstPrint() {
		std::cout << "姓名:" << name << std::endl;
		std::cout << "年龄:" << age << std::endl;
	}
	std::string name="小鱼同学";
	int age=18;
};
class student :public person{
public:
	void Print() {
		FirstPrint();
		std::cout << name << std::endl;
		std::cout << age << std::endl;
		std::cout << num << std::endl;
	}
	std::string num="2209109016";
};
class teacher :public person {
public:
	std::string work_num="2213";
};
class someone :public student,public teacher {
public:
	std::string onlyid = "546121156152312asd";
};
void test_1()//本次测试证明，派生类继承基类，就相当于将基类的成员当成自己的成员
{             //但并不是盲目接纳父类成员，而是只接受不受private限制的成员
	student xy;
	xy.FirstPrint();
	return;
}
void test_2()
{
	//切割测试,当将原本指向派生类的父类指针经过强制类型转换赋值给派生类指针时，不会发生错误
	student s;
	person  p1 = s;
	person& p2 = s;
	person* p3 = &s;

	student* s2 = (student*)p3;//p3指向派生类对象的地址
	std::cout <<"s2->num:" << s2->num << std::endl;

	student* s3 = (student*)(&p1);//&p1指向基类对象的地址
	std::cout << "s3->num:" << s3->num << std::endl;
}
void test_3()
{
	someone e;
	e.student::name ="小明";
	e.teacher::name ="小红";
}
class A {
public:
	int A_value;
};
//class B :public A
class B :virtual public A
{
public:
	int B_value;
};
//class C :public A 
class C:virtual public A
{
public:
	int C_value;
};
class D :public B, public C {
public:
	int D_value;
};
void test_4()//测试菱形继承
{
	D tmp_d;
	tmp_d.A_value = 1;
	tmp_d.B_value = 3;
	tmp_d.C_value = 4;
	tmp_d.D_value = 5;
}


int main() {
	test_4();
	return 0;
}